<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>发布讨论 - 邻里社区</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary: #FF6B6B;
            --primary-gradient: linear-gradient(135deg, #FF6B6B 0%, #FF8E8E 100%);
            --secondary: #4ECDC4;
            --accent: #FFD166;
            --dark: #1A535C;
            --light: #F7F9FC;
            --community: #5B8CFF;
            --transaction: #7CE0D3;
            --success: #4CAF50;
            --warning: #FF9800;
            --danger: #F44336;
            --card-shadow: 0 8px 20px rgba(255, 107, 107, 0.2);
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Nunito', 'PingFang SC', sans-serif;
            -webkit-tap-highlight-color: transparent;
        }
        
        body {
            background: linear-gradient(135deg, #fce8e8 0%, #f5f7fa 100%);
            color: #333;
            min-height: 100vh;
            overflow-x: hidden;
            padding-bottom: constant(safe-area-inset-bottom);
            padding-bottom: env(safe-area-inset-bottom);
        }
        
        .container {
            width: 100%;
            max-width: 100%;
            padding: 15px;
            margin: 0 auto;
        }
        
        /* 顶部导航 */
        .header {
            display: flex;
            align-items: center;
            margin-bottom: 20px;
            padding-top: 10px;
            position: sticky;
            top: 0;
            z-index: 100;
            background: linear-gradient(135deg, #fce8e8 0%, #f5f7fa 100%);
            padding-bottom: 10px;
        }
        
        .back-btn {
            width: 44px;
            height: 44px;
            background: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 12px;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            color: var(--primary);
            font-size: 18px;
            cursor: pointer;
        }
        
        h1 {
            font-size: 22px;
            font-weight: 800;
            background: var(--primary-gradient);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        /* 表单样式 */
        .post-form {
            background: white;
            border-radius: 20px;
            padding: 20px;
            box-shadow: var(--card-shadow);
            margin-bottom: 20px;
            position: relative;
            overflow: hidden;
        }
        
        .post-form::before {
            content: '';
            position: absolute;
            top: -15px;
            right: -15px;
            width: 80px;
            height: 80px;
            background: var(--primary-gradient);
            border-radius: 50%;
            opacity: 0.1;
            z-index: 0;
        }
        
        .form-group {
            margin-bottom: 20px;
            position: relative;
            z-index: 1;
        }
        
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 700;
            color: var(--dark);
            font-size: 16px;
        }
        
        input[type="text"], textarea {
            width: 100%;
            padding: 16px;
            border: 2px solid #e8e8e8;
            border-radius: 16px;
            font-size: 16px;
            transition: all 0.3s ease;
            background: #fafafa;
            -webkit-appearance: none;
        }
        
        input[type="text"]:focus, textarea:focus {
            border-color: var(--primary);
            outline: none;
            background: white;
            box-shadow: 0 4px 12px rgba(255, 107, 107, 0.1);
        }
        
        textarea {
            min-height: 120px;
            resize: vertical;
        }
        
        /* 图片上传 */
        .image-upload {
            margin-bottom: 20px;
        }
        
        .upload-area {
            border: 2px dashed #ffbaba;
            border-radius: 16px;
            padding: 25px 15px;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s ease;
            background: rgba(255, 107, 107, 0.05);
        }
        
        .upload-area:active {
            background: rgba(255, 107, 107, 0.1);
            transform: scale(0.98);
        }
        
        .upload-icon {
            font-size: 36px;
            color: var(--primary);
            margin-bottom: 10px;
        }
        
        .upload-text {
            color: #666;
            font-weight: 600;
            font-size: 15px;
        }
        
        .image-preview {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            margin-top: 15px;
        }
        
        .preview-item {
            position: relative;
            width: 80px;
            height: 80px;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        }
        
        .preview-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        .remove-image {
            position: absolute;
            top: 5px;
            right: 5px;
            background: rgba(0, 0, 0, 0.6);
            color: white;
            width: 24px;
            height: 24px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
        }
        
        /* 隐私设置 */
        .privacy-section {
            background: linear-gradient(135deg, rgba(255, 107, 107, 0.1) 0%, rgba(255, 142, 142, 0.1) 100%);
            border-radius: 16px;
            padding: 20px;
            margin-bottom: 20px;
            border: 2px solid rgba(255, 107, 107, 0.2);
        }
        
        .privacy-title {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }
        
        .privacy-title i {
            font-size: 20px;
            color: var(--primary);
            margin-right: 10px;
        }
        
        .privacy-title h3 {
            font-size: 18px;
            font-weight: 800;
            color: var(--dark);
        }
        
        .privacy-options {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }
        
        .privacy-option {
            background: white;
            border-radius: 14px;
            padding: 16px;
            cursor: pointer;
            transition: all 0.3s ease;
            border: 2px solid transparent;
            position: relative;
            overflow: hidden;
        }
        
        .privacy-option.selected {
            border-color: var(--primary);
            box-shadow: 0 5px 15px rgba(255, 107, 107, 0.15);
        }
        
        .privacy-option::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 4px;
            height: 100%;
            background: var(--primary-gradient);
            opacity: 0;
            transition: opacity 0.3s ease;
        }
        
        .privacy-option.selected::before {
            opacity: 1;
        }
        
        .option-header {
            display: flex;
            align-items: center;
            margin-bottom: 8px;
        }
        
        .option-header input[type="radio"] {
            margin-right: 10px;
            width: 20px;
            height: 20px;
            accent-color: var(--primary);
        }
        
        .option-header label {
            margin-bottom: 0;
            font-size: 16px;
            cursor: pointer;
        }
        
        .option-desc {
            color: #666;
            font-size: 14px;
            margin-left: 30px;
        }
        
        .privacy-notice {
            display: flex;
            align-items: center;
            background: rgba(255, 107, 107, 0.1);
            color: var(--primary);
            padding: 12px;
            border-radius: 12px;
            margin-top: 15px;
            font-size: 14px;
            border: 1px dashed var(--primary);
        }
        
        .privacy-notice i {
            margin-right: 8px;
            font-size: 16px;
        }
        
        /* 按钮 */
        .action-buttons {
            display: flex;
            gap: 12px;
            position: sticky;
            bottom: 20px;
            z-index: 10;
        }
        
        .btn {
            flex: 1;
            padding: 16px;
            border: none;
            border-radius: 16px;
            font-size: 16px;
            font-weight: 700;
            cursor: pointer;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .btn:active {
            transform: scale(0.98);
        }
        
        .btn-primary {
            background: var(--primary-gradient);
            color: white;
            box-shadow: 0 5px 15px rgba(255, 107, 107, 0.3);
        }
        
        .btn-primary:active {
            box-shadow: 0 3px 10px rgba(255, 107, 107, 0.4);
        }
        
        .btn-outline {
            background: transparent;
            border: 2px solid #ccc;
            color: #666;
        }
        
        .btn-outline:active {
            border-color: var(--primary);
            color: var(--primary);
        }
        
        /* 浮动形状 */
        .floating-shapes {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: -1;
        }
        
        .shape {
            position: absolute;
            border-radius: 50%;
            opacity: 0.15;
        }
        
        .shape-1 {
            width: 80px;
            height: 80px;
            background: var(--primary);
            top: 10%;
            left: 5%;
            animation: float 15s infinite ease-in-out;
        }
        
        .shape-2 {
            width: 60px;
            height: 60px;
            background: var(--accent);
            bottom: 15%;
            right: 10%;
            animation: float 12s infinite ease-in-out reverse;
        }
        
        @keyframes float {
            0%, 100% { transform: translateY(0) rotate(0deg); }
            50% { transform: translateY(-15px) rotate(10deg); }
        }
        
        /* 响应式调整 */
        @media (max-width: 480px) {
            .container {
                padding: 12px;
            }
            
            .post-form {
                padding: 18px;
                border-radius: 18px;
            }
            
            h1 {
                font-size: 20px;
            }
            
            input[type="text"], textarea {
                padding: 14px;
                font-size: 16px;
            }
            
            .privacy-section {
                padding: 16px;
            }
            
            .privacy-option {
                padding: 14px;
            }
            
            .btn {
                padding: 14px;
                font-size: 15px;
            }
            
            .preview-item {
                width: 70px;
                height: 70px;
            }
        }
        
        /* 安全区域适配 */
        @supports(padding: max(0px)) {
            .header, .container {
                padding-left: max(15px, env(safe-area-inset-left));
                padding-right: max(15px, env(safe-area-inset-right));
            }
            
            .action-buttons {
                padding-bottom: max(20px, env(safe-area-inset-bottom));
            }
        }
    </style>
</head>
<body>
    <div class="floating-shapes">
        <div class="shape shape-1"></div>
        <div class="shape shape-2"></div>
    </div>
    
    <div class="container">
        <div class="header">
            <div class="back-btn">
                <i class="fas fa-arrow-left"></i>
            </div>
            <h1>发布讨论</h1>
        </div>
        
        <div class="post-form">
            <div class="form-group">
                <label for="post-title">标题</label>
                <input type="text" id="post-title" placeholder="请输入讨论标题">
            </div>
            
            <div class="form-group">
                <label for="post-content">内容</label>
                <textarea id="post-content" placeholder="分享您的想法或问题..."></textarea>
            </div>
            
            <div class="image-upload">
                <label>添加图片（可选）</label>
                <div class="upload-area" id="upload-area">
                    <div class="upload-icon">
                        <i class="fas fa-cloud-upload-alt"></i>
                    </div>
                    <div class="upload-text">点击或拖拽图片到此处</div>
                </div>
                <div class="image-preview" id="image-preview"></div>
            </div>
            
            <div class="privacy-section">
                <div class="privacy-title">
                    <i class="fas fa-lock"></i>
                    <h3>位置隐私设置</h3>
                </div>
                
                <div class="privacy-options">
                    <div class="privacy-option selected" data-level="3">
                        <div class="option-header">
                            <input type="radio" name="privacy" id="privacy-high" checked>
                            <label for="privacy-high">高隐私保护</label>
                        </div>
                        <p class="option-desc">仅显示小区名称: "幸福小区"</p>
                    </div>
                    
                    <div class="privacy-option" data-level="2">
                        <div class="option-header">
                            <input type="radio" name="privacy" id="privacy-medium">
                            <label for="privacy-medium">中等隐私</label>
                        </div>
                        <p class="option-desc">显示楼栋信息: "幸福小区·3号楼"</p>
                    </div>
                    
                    <div class="privacy-option" data-level="1">
                        <div class="option-header">
                            <input type="radio" name="privacy" id="privacy-low">
                            <label for="privacy-low">低隐私保护</label>
                        </div>
                        <p class="option-desc">显示完整地址: "幸福小区·3号楼2单元301室"</p>
                    </div>
                </div>
                
                <div class="privacy-notice">
                    <i class="fas fa-info-circle"></i>
                    <span>您的详细地址仅用于邻里互动，不会被公开或用于其他用途</span>
                </div>
            </div>
        </div>
        
        <div class="action-buttons">
            <button class="btn btn-outline">取消</button>
            <button class="btn btn-primary">
                <i class="fas fa-paper-plane" style="margin-right: 8px;"></i>
                发布讨论
            </button>
        </div>
    </div>

    <script>
        // 图片上传预览功能
        const uploadArea = document.getElementById('upload-area');
        const imagePreview = document.getElementById('image-preview');
        const selectedFiles = [];
        
        uploadArea.addEventListener('click', () => {
            const input = document.createElement('input');
            input.type = 'file';
            input.accept = 'image/*';
            input.multiple = true;
            input.addEventListener('change', handleFileSelect);
            input.click();
        });
        
        uploadArea.addEventListener('dragover', (e) => {
            e.preventDefault();
            uploadArea.style.borderColor = '#FF6B6B';
            uploadArea.style.background = 'rgba(255, 107, 107, 0.15)';
        });
        
        uploadArea.addEventListener('dragleave', () => {
            uploadArea.style.borderColor = '#ffbaba';
            uploadArea.style.background = 'rgba(255, 107, 107, 0.05)';
        });
        
        uploadArea.addEventListener('drop', (e) => {
            e.preventDefault();
            uploadArea.style.borderColor = '#ffbaba';
            uploadArea.style.background = 'rgba(255, 107, 107, 0.05)';
            handleFiles(e.dataTransfer.files);
        });
        
        function handleFileSelect(e) {
            handleFiles(e.target.files);
        }
        
        function handleFiles(files) {
            for (let i = 0; i < files.length; i++) {
                if (selectedFiles.length >= 9) {
                    alert('最多只能上传9张图片');
                    break;
                }
                
                const file = files[i];
                if (!file.type.match('image.*')) continue;
                
                selectedFiles.push(file);
                previewImage(file);
            }
        }
        
        function previewImage(file) {
            const reader = new FileReader();
            reader.onload = function(e) {
                const previewItem = document.createElement('div');
                previewItem.className = 'preview-item';
                
                const img = document.createElement('img');
                img.src = e.target.result;
                
                const removeBtn = document.createElement('div');
                removeBtn.className = 'remove-image';
                removeBtn.innerHTML = '<i class="fas fa-times"></i>';
                removeBtn.addEventListener('click', () => {
                    const index = selectedFiles.indexOf(file);
                    if (index > -1) {
                        selectedFiles.splice(index, 1);
                    }
                    imagePreview.removeChild(previewItem);
                });
                
                previewItem.appendChild(img);
                previewItem.appendChild(removeBtn);
                imagePreview.appendChild(previewItem);
            };
            reader.readAsDataURL(file);
        }
        
        // 隐私选项选择
        const privacyOptions = document.querySelectorAll('.privacy-option');
        privacyOptions.forEach(option => {
            option.addEventListener('click', () => {
                privacyOptions.forEach(opt => opt.classList.remove('selected'));
                option.classList.add('selected');
                const radio = option.querySelector('input[type="radio"]');
                radio.checked = true;
            });
        });
        
        // 表单提交
        document.querySelector('.btn-primary').addEventListener('click', () => {
            const title = document.getElementById('post-title').value;
            const content = document.getElementById('post-content').value;
            const privacyLevel = document.querySelector('input[name="privacy"]:checked').parentNode.parentNode.parentNode.getAttribute('data-level');
            
            if (!title || !content) {
                alert('请填写标题和内容');
                return;
            }
            
            // 这里应该是实际的提交逻辑
            console.log('发布内容:', {
                title,
                content,
                images: selectedFiles.length,
                privacyLevel: parseInt(privacyLevel)
            });
            
            // 显示成功提示
            const successMsg = document.createElement('div');
            successMsg.style.cssText = `
                position: fixed;
                top: 20px;
                right: 20px;
                padding: 15px 20px;
                background: var(--primary-gradient);
                color: white;
                border-radius: 12px;
                box-shadow: 0 5px 15px rgba(0,0,0,0.2);
                z-index: 1000;
                font-weight: 600;
                transform: translateX(100%);
                transition: transform 0.3s ease;
                font-size: 15px;
            `;
            successMsg.innerHTML = '<i class="fas fa-check-circle" style="margin-right: 8px;"></i> 发布成功！';
            document.body.appendChild(successMsg);
            
            // 显示动画
            setTimeout(() => successMsg.style.transform = 'translateX(0)', 10);
            
            // 2秒后消失
            setTimeout(() => {
                successMsg.style.transform = 'translateX(100%)';
                setTimeout(() => document.body.removeChild(successMsg), 300);
            }, 2000);
        });
        
        // 返回按钮功能
        document.querySelector('.back-btn').addEventListener('click', () => {
            if (document.getElementById('post-title').value || document.getElementById('post-content').value) {
                if (confirm('您有未保存的内容，确定要返回吗？')) {
                    window.history.back();
                }
            } else {
                window.history.back();
            }
        });
    </script>
</body>
</html>